package com.gopay.common.cps.dao.cbrmb.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.cbrmb.CbRmbIntlCardDishonorRuleDAO;
import com.gopay.common.domain.cbrmb.internationalcard.CbRmbIntlCardDishonorRule;

/**
 * 
 * @ClassName: CbRmbIntlCardDishonorRuleDAOImpl
 * @Description: TODO
 * @author gd.cui
 * @date 2017年10月31日 下午1:47:16
 */
@Repository(value = "cbRmbIntlCardDishonorRuleDAO")
public class CbRmbIntlCardDishonorRuleDAOImpl extends BaseDAOImpl<CbRmbIntlCardDishonorRule, Long>
		implements CbRmbIntlCardDishonorRuleDAO {

	@Override
	public CbRmbIntlCardDishonorRule findByCustId(String custId) {
		String hql = "from CbRmbIntlCardDishonorRule where custId ='" + custId+"'";
		List<CbRmbIntlCardDishonorRule> list = findByHql(hql);
		if (list != null && list.size() > 0) {
			return list.get(0);
		} else {
			return null;
		}
	}

	@Override
	public List<CbRmbIntlCardDishonorRule> getGeneralRule() {
		String hql = "from CbRmbIntlCardDishonorRule where custId is null";
		List<CbRmbIntlCardDishonorRule> lists = findByHql(hql);
		if (lists != null && lists.size() > 0) {
			return lists;
		} else {
			lists = new ArrayList<CbRmbIntlCardDishonorRule>();
			CbRmbIntlCardDishonorRule rule=new CbRmbIntlCardDishonorRule();
			rule.setIsAdd("0");
			lists.add(rule);
			return lists;
		}
	}

}
